#include<iostream>
#include<algorithm>
using namespace std;
#define int long long
int n;
const int N = 25;
string a[N];
bool cmp(string &x , string &y)
{
    return x + y > y + x;
}
signed main()
{
    cin >> n;
    for(int i = 1;i <= n;i ++) cin >> a[i];
    sort(a + 1 , a + 1 + n , cmp);
    for(int i = 1;i <= n;i ++) cout << a[i];
    return 0;
}